﻿using System.Collections.Generic;
using System.Web.Mvc;
using FluentValidation;
using FluentValidation.Attributes;
using Nop.Services.Localization;
using Nop.Web.Framework;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc;
using System.ComponentModel.DataAnnotations;
using Nop.Web.Framework.Validators;

namespace Nop.Plugin.Widgets.AllInOne.Models
{
    [Validator(typeof(AllInOneValidator))]
    public partial class AllInOneModel : BaseNopEntityModel
    {
        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.Name")]
        public string Name { get; set; }

        [AllowHtml]
        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.HtmlCode")]
        public string HtmlCode { get; set; }

        [AllowHtml]
        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.HtmlCodeExtra")]
        public string HtmlCodeExtra { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.WidgetZone")]
        public string WidgetZone { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.Published")]
        public bool Published { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.DisplayOrder")]
        public int DisplayOrder { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.jsFileList")]
        public string jsFileList { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.AllInOne.Fields.cssFileList")]
        public string cssFileList { get; set; }

    }


    public class AllInOneValidator : BaseNopValidator<AllInOneModel>
    {
        public AllInOneValidator(ILocalizationService localizationService)
        {
            RuleFor(x => x.Name).NotNull().WithMessage(localizationService.GetResource("Plugins.Widgets.AllInOne.Fields.Name.Required"));
            RuleFor(x => x.WidgetZone).NotNull().WithMessage(localizationService.GetResource("Plugins.Widgets.AllInOne.Fields.WidgetZone.Required"));
            RuleFor(x => x.HtmlCode).NotNull().WithMessage(localizationService.GetResource("Plugins.Widgets.AllInOne.Fields.HtmlCode.Required"));
            //RuleFor(x => x.HtmlCodeExtra).NotNull().WithMessage(localizationService.GetResource("Plugins.Widgets.AllInOne.Fields.HtmlCodeExtra.Required"));
        }
    }
}